// var i;
// var $resKeeper = require("./ResKeeper");
// var $nodePoolMag = require("./NodePoolMag");
// var l = cc._decorator;
// var u = l.ccclass;
// var d = (l.property, l.inspector);
// var p = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.baozaAni = null;
//         t.bingbaoAni = null;
//         t.yintaobaozha = null;
//         return t;
//     }
//     __extends(t, e);
//     t.prototype.onEnable = function () {};
//     t.prototype.playBaoZa = function (e) {
//         if (void 0 === e) {
//             e = 100;
//         }
//         if (e < 100) {
//             e = 100;
//         }
//         this.node.scale = 1 + e / 100;
//         this.node.children.forEach(function (e) {
//             e.active = !1;
//         });
//         this.baozaAni = this.node.children[0].getComponent(dragonBones.ArmatureDisplay);
//         this.baozaAni.node.active = !0;
//         this.baozaAni.playAnimation("newAnimation", 1);
//         this.baozaAni.addEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.onAniState, this);
//     };
//     t.prototype.playBingBao = function () {
//         this.node.scale = 3;
//         this.node.children.forEach(function (e) {
//             e.active = !1;
//         });
//         this.bingbaoAni = this.node.children[1].getComponent(dragonBones.ArmatureDisplay);
//         this.bingbaoAni.node.active = !0;
//         this.bingbaoAni.playAnimation("bingbao", 1);
//         this.bingbaoAni.timeScale = 1.5;
//         this.bingbaoAni.addEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.onAniState, this);
//     };
//     t.prototype.playYinTaoBaoZha = function (e) {
//         if (void 0 === e) {
//             e = 100;
//         }
//         if (e < 100) {
//             e = 100;
//         }
//         this.node.scale = 1 + (e / 100) * 0.5;
//         this.node.children.forEach(function (e) {
//             e.active = !1;
//         });
//         this.yintaobaozha = this.node.children[2].getComponent(cc.Animation);
//         this.yintaobaozha.node.active = !0;
//         this.yintaobaozha.play();
//         this.scheduleOnce(this.onAniState, 1);
//     };
//     t.prototype.onAniState = function () {
//         $nodePoolMag.NodePoolMag.instance.recycleNode("baozha", this.node);
//     };
//     t.prototype.onDisable = function () {
//         if (this.baozaAni && this.baozaAni.node.active) {
//             this.baozaAni.removeEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.onAniState, this);
//         }
//         if (this.bingbaoAni && this.bingbaoAni.node.active) {
//             this.bingbaoAni.removeEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.onAniState, this);
//         }
//     };
//     return __decorate([u], t);
// })($resKeeper.default);
// exports.default = p;

// import ResKeeper from "./ResKeeper";
// import { NodePoolMag } from "./NodePoolMag";

// const { ccclass, property, inspector } = cc._decorator;

// /**
//  * 建议类名: ExplosionManager
//  */
// @ccclass
// class UI_BaoZha extends ResKeeper {
//     @property(dragonBones.ArmatureDisplay)
//     private baozaAni: dragonBones.ArmatureDisplay = null;

//     @property(dragonBones.ArmatureDisplay)
//     private bingbaoAni: dragonBones.ArmatureDisplay = null;

//     @property(cc.Animation)
//     private yintaobaozha: cc.Animation = null;

//     onEnable(): void { }

//     /**
//      * 播放爆炸动画
//      * @param scaleFactor 缩放因子
//      * 建议方法名: playExplosion
//      */
//     playBaoZa(scaleFactor: number = 100): void {
//         if (scaleFactor < 100) {
//             scaleFactor = 100;
//         }
//         this.node.scale = 1 + scaleFactor / 100;
//         this.node.children.forEach((child) => {
//             child.active = false;
//         });
//         this.baozaAni = this.node.children[0].getComponent(dragonBones.ArmatureDisplay);
//         this.baozaAni.node.active = true;
//         this.baozaAni.playAnimation("newAnimation", 1);
//         this.baozaAni.addEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.onAniState, this);
//     }

//     /**
//      * 播放冰爆动画
//      * 建议方法名: playIceExplosion
//      */
//     playBingBao(): void {
//         this.node.scale = 3;
//         this.node.children.forEach((child) => {
//             child.active = false;
//         });
//         this.bingbaoAni = this.node.children[1].getComponent(dragonBones.ArmatureDisplay);
//         this.bingbaoAni.node.active = true;
//         this.bingbaoAni.playAnimation("bingbao", 1);
//         this.bingbaoAni.timeScale = 1.5;
//         this.bingbaoAni.addEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.onAniState, this);
//     }

//     /**
//      * 播放樱桃爆炸动画
//      * @param scaleFactor 缩放因子
//      * 建议方法名: playCherryExplosion
//      */
//     playYinTaoBaoZha(scaleFactor: number = 100): void {
//         if (scaleFactor < 100) {
//             scaleFactor = 100;
//         }
//         this.node.scale = 1 + (scaleFactor / 100) * 0.5;
//         this.node.children.forEach((child) => {
//             child.active = false;
//         });
//         this.yintaobaozha = this.node.children[2].getComponent(cc.Animation);
//         this.yintaobaozha.node.active = true;
//         this.yintaobaozha.play();
//         this.scheduleOnce(this.onAniState, 1);
//     }

//     /**
//      * 动画状态回调
//      * 建议方法名: onAnimationState
//      */
//     private onAniState(): void {
//         NodePoolMag.instance.recycleNode("baozha", this.node);
//     }

//     onDisable(): void {
//         if (this.baozaAni && this.baozaAni.node.active) {
//             this.baozaAni.removeEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.onAniState, this);
//         }
//         if (this.bingbaoAni && this.bingbaoAni.node.active) {
//             this.bingbaoAni.removeEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.onAniState, this);
//         }
//     }
// }

// export default UI_BaoZha;

import ResKeeper from "./ResKeeper";
import { NodePoolMag } from "./NodePoolMag";

const { ccclass, property, inspector } = cc._decorator;

/**
 * 建议类名: ExplosionManager
 */
@ccclass
class ViewBaoZha extends ResKeeper {
    @property(dragonBones.ArmatureDisplay)
    private explosionAnimation: dragonBones.ArmatureDisplay = null;

    @property(dragonBones.ArmatureDisplay)
    private iceExplosionAnimation: dragonBones.ArmatureDisplay = null;

    @property(cc.Animation)
    private cherryExplosionAnimation: cc.Animation = null;

    onEnable(): void { }

    /**
     * 播放爆炸动画
     * @param scaleFactor 缩放因子
     * 建议方法名: playExplosion
     */
    playExplosion(scaleFactor: number = 100): void {
        const adjustedScaleFactor = scaleFactor < 100 ? 100 : scaleFactor;
        this.node.scale = 1 + adjustedScaleFactor / 100;

        this.node.children.forEach((child) => {
            child.active = false;
        });

        this.explosionAnimation = this.node.children[0].getComponent(dragonBones.ArmatureDisplay);
        this.explosionAnimation.node.active = true;
        this.explosionAnimation.playAnimation("newAnimation", 1);
        this.explosionAnimation.addEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.onAnimationState, this);
    }

    /**
     * 播放冰爆动画
     * 建议方法名: playIceExplosion
     */
    playIceExplosion(): void {
        this.node.scale = 3;

        this.node.children.forEach((child) => {
            child.active = false;
        });

        this.iceExplosionAnimation = this.node.children[1].getComponent(dragonBones.ArmatureDisplay);
        this.iceExplosionAnimation.node.active = true;
        this.iceExplosionAnimation.playAnimation("bingbao", 1);
        this.iceExplosionAnimation.timeScale = 1.5;
        this.iceExplosionAnimation.addEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.onAnimationState, this);
    }

    /**
     * 播放樱桃爆炸动画
     * @param scaleFactor 缩放因子
     * 建议方法名: playCherryExplosion
     */
    playCherryExplosion(scaleFactor: number = 100): void {
        const adjustedScaleFactor = scaleFactor < 100 ? 100 : scaleFactor;
        this.node.scale = 1 + (adjustedScaleFactor / 100) * 0.5;

        this.node.children.forEach((child) => {
            child.active = false;
        });

        this.cherryExplosionAnimation = this.node.children[2].getComponent(cc.Animation);
        this.cherryExplosionAnimation.node.active = true;
        this.cherryExplosionAnimation.play();
        this.scheduleOnce(this.onAnimationState, 1);
    }

    /**
     * 动画状态回调
     * 建议方法名: onAnimationState
     */
    private onAnimationState(): void {
        NodePoolMag.instance.recycleNodeToPool("baozha", this.node);
    }

    onDisable(): void {
        if (this.explosionAnimation && this.explosionAnimation.node.active) {
            this.explosionAnimation.removeEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.onAnimationState, this);
        }
        if (this.iceExplosionAnimation && this.iceExplosionAnimation.node.active) {
            this.iceExplosionAnimation.removeEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.onAnimationState, this);
        }
    }
}

export default ViewBaoZha;